
function deleteMovieRootDir(movie) {
    delete movie.rootDir
}

function changeMovieName(movie) {
    const movieName = `${movie.year}\.${movie.name}\.`
    for (let dreamVideo of movie.dreamVideos) {
        dreamVideo.name = dreamVideo.name.replace(new RegExp(`^${movieName}`), '')
    }
}

const low = require('lowdb')
const FileSync = require('lowdb/adapters/FileSync')

const dataBaseDir = 'E:/code/electron/dream/src/data/'

const db = low(new FileSync(`${dataBaseDir}/movie.json`))

const movies = db.read()
    .get('movies')
    .value()
for (let movie of movies) {
    deleteMovieRootDir(movie)
    console.log(movie)
}

// Writing data back to the database after modifications
db.write()
